package com.example.user.presenter;

import com.example.baselibrary.presenter.BasePresenter;
import com.example.baselibrary.rx.BaseObserver;
import com.example.baselibrary.rx.BaseResponseTransformer;
import com.example.baselibrary.utils.ZLog;
import com.example.user.iview.LoginView;
import com.example.user.service.UserService;
import com.example.user.service.impl.UserServiceImpl;

import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.ObservableTransformer;
import retrofit2.Response;


/**
 * 登录界面 Presenter by zqq on 2018/6/11.
 */

public class LoginPresenter extends BasePresenter<LoginView> {

    private UserService userService;

    public LoginPresenter() {
        userService = new UserServiceImpl();
    }

    public void Login() {
        if (!checkNetWork()) {
            return;
        }
        mView.showLoading();
        userService.login()
                .compose(new BaseResponseTransformer<String, Object>())
                .subscribe(new BaseObserver<String>(mView) {
                    @Override
                    public void onNext(String s) {
                        super.onNext(s);
                        ZLog.e(s);
                        mView.onLoginResult(s);
                    }
                });
    }

}
